package com.threegroup.android3grouppersonality.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.threegroup.android3grouppersonality.R;
import com.threegroup.android3grouppersonality.ui.fragment.HomeFragment;
import com.threegroup.android3grouppersonality.ui.fragment.MeFragment;
import com.threegroup.android3grouppersonality.ui.fragment.MessageFragment;
import com.threegroup.android3grouppersonality.ui.fragment.NearbyFragment;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private RelativeLayout bottomHome;
    private RelativeLayout bottomHeat;
    private RelativeLayout bottomMessane;
    private RelativeLayout bottomMe;
    private RelativeLayout pub_add_to;

    private HomeFragment homeFragment;

    private MeFragment meFragment;

    private NearbyFragment nearbyFragment;
    private MessageFragment messageFragment;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

    }

    private void initView() {
        bottomHome = findViewById(R.id.bottomHome);
        bottomHeat = findViewById(R.id.bottomHeat);
        bottomMessane = findViewById(R.id.Mesagebtn);
        bottomMe = findViewById(R.id.bottomMe);
        pub_add_to=findViewById(R.id.pub_add_to);

        bottomHome.setOnClickListener(this);
        bottomHeat.setOnClickListener(this);
        bottomMessane.setOnClickListener(this);
        bottomMe.setOnClickListener(this);
        pub_add_to.setOnClickListener(this);

        homeFragment = new HomeFragment();
        meFragment = new MeFragment();
        nearbyFragment=new NearbyFragment();
        messageFragment =new MessageFragment();

        getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,homeFragment).commit();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bottomHome:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,homeFragment).commit();
                break;
            case R.id.bottomHeat:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,nearbyFragment).commit();
                break;
            case R.id.Mesagebtn:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,messageFragment).commit();
                break;
            case R.id.bottomMe:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,meFragment).commit();
                break;
            case R.id.pub_add_to:
                Intent intent=new Intent(this,BlogPublishActivity.class);
                startActivity(intent);
                break;
        }

    }
}